You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
808 B
19 lines
808 B
import { getPublicPostCommentContext } from "#server/service/posts";
|
|
import { listCommentsPayload } from "#server/service/post-comments";
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const publicSlug = event.context.params?.publicSlug;
|
|
const postSlug = event.context.params?.postSlug;
|
|
if (!publicSlug || !postSlug || typeof publicSlug !== "string" || typeof postSlug !== "string") {
|
|
throw createError({ statusCode: 400, statusMessage: "无效请求" });
|
|
}
|
|
|
|
const ctx = await getPublicPostCommentContext(publicSlug, postSlug);
|
|
if (!ctx) {
|
|
throw createError({ statusCode: 404, statusMessage: "未找到" });
|
|
}
|
|
|
|
const viewer = await event.context.auth.getCurrent();
|
|
const data = await listCommentsPayload(ctx.id, ctx.userId, viewer?.id ?? null);
|
|
return R.success(data);
|
|
});
|
|
|